{% extends "admin/change_form.html" %}
{% comment %}{% load snippet_media %}{% endcomment %}

{% block extrahead %}
{{ block.super }}
{% comment %}<script src="{% load_media %}" type="text/javascript"></script>{% endcomment %}

<script type="text/javascript">
    tinyMCE.init({
        language: "ru",
        theme : "advanced",
        skin : "default",
        width: "700px",
        height: "400px",
        relative_urls : false,
        remove_script_host : true,

        plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1 : "fullscreen,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,

        template_external_list_url : "js/template_list.js",
        external_link_list_url : "js/link_list.js",
        external_image_list_url : "js/image_list.js",
        media_external_list_url : "js/media_list.js"
    });

django.jQuery(document).ready(function($){
    var editor = $('textarea')[0];
    var filter_id = '#id_filter';
    load_editor();
    function load_editor(){
        if ($(filter_id).val() == 2) tinyMCE.execCommand( 'mceAddControl', true, editor);
        else tinyMCE.execCommand( 'mceRemoveControl', true, editor);
    }
    $(filter_id).change(load_editor);
});
</script>
{% endblock %}